package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Date;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

    @Autowired
    private ${table.mapperName} ${table.mapperName?uncap_first};

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void create(${entity} ${entity?uncap_first}) {
        ${table.mapperName?uncap_first}.insert(${entity?uncap_first});
    }

    @Override
    public void delete(Integer id) {
        removeById(id);
    }

    @Override
    public void deleteBatch(List<Integer> ids) {
        removeByIds(ids);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(${entity} ${entity?uncap_first}) {
        ${table.mapperName?uncap_first}.updateById(${entity?uncap_first});
    }

    @Override
    public ${entity} get(Integer id) {
        ${entity} ${entity?uncap_first} = getById(id);
        return ${entity?uncap_first};
    }

    @Override
    public PageInfo<${entity}> query(${entity} ${entity?uncap_first},int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<${entity}> ${entity?uncap_first}List = ${table.mapperName?uncap_first}.query(${entity?uncap_first});
        PageInfo<${entity}> pageInfo = new PageInfo<>(${entity?uncap_first}List);
        return pageInfo;
    }


}
</#if>